version: '3.8'

services:
  backend:
    restart: unless-stopped
    container_name: backend
    build: 
      context: ./backend
      target: dev
    command: uvicorn main:app --reload --host 0.0.0.0 --port 5000 --use-colors 
             # --log-config=src/logging.dev.yaml
             # --log-config=src/logging.yaml 
             # --log-level trace
             # --log-level [critical|error|warning|info|debug|trace]
    stop_signal: SIGKILL
    volumes:
      - ./backend:/app
    secrets:
      - recaptcha_secret
    labels:
      - traefik.enable=true
      - traefik.http.services.backend.loadbalancer.server.port=5000
      - traefik.http.routers.backend.rule=PathPrefix(`/ws/`)

  ui:
    restart: unless-stopped
    container_name: ui
    build: 
      context: ./ui
      target: prod
    volumes:
      - ./ui:/app
    command: ["vite", "preview", "--port", "8008", "--host"]
#    command: tail -f /dev/null
    stop_signal: SIGKILL   
    labels:
      - traefik.enable=true
      - traefik.http.services.ui.loadbalancer.server.port=8008
      - traefik.http.routers.ui.rule=PathPrefix(`/`)

  traefik:
    restart: unless-stopped
    container_name: traefik
    image: traefik:latest
    ports:
      - 127.0.0.1:11000:80
#      - 8080:8080  # The Web UI (enabled by --api.insecure=true)
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /etc/localtime:/etc/localtime:ro    
      - ./traefik/traefik.local.yml:/traefik.yml:ro
    stop_signal: SIGKILL
secrets:
  recaptcha_secret:
    file: ~/gurren/recaptcha_secret.txt
